﻿<!DOCTYPE html>
<html lang="en">
<#include "../common/common-head.html"/>
<link>
<body class="gray-bg top-navigation">
<div id="wrapper">
    <div id="page-wrapper" class="gray-bg">
    <#include "../common/common-menu.html">
        <div class="wrapper wrapper-content">
            <div class="row white-bg" style="padding: 18px 0">
                <div class="col-xs-12">
                    <div class="form-search">
                        <form role="form" class="form-inline clearfix" id="form" action="">
                        <@search labels=["产品名称","客服","会员名","店铺筛选"] names=["name","kefu","member","user"] isEnd=false></@search>
                            <div class="input-group">
                                <span class="input-group-addon">出发时间</span>
                                <input name="starttime" class="form-control date-picker col-xs-4" type="text"
                                       value="${starttime!}" data-date-format="yyyy-mm-dd">
                                <span class="input-group-addon">至</span>
                                <input name="endtime" class="form-control date-picker col-xs-4" type="text"
                                       value="${endtime!}" data-date-format="yyyy-mm-dd">
                            </div>
                            <div class="input-group">
                                <span class="input-group-addon">登记时间</span>
                                <input name="starttime1" class="form-control date-picker col-xs-4" type="text"
                                       value="${starttime1!}" data-date-format="yyyy-mm-dd">
                                <span class="input-group-addon">至</span>
                                <input name="endtime1" class="form-control date-picker col-xs-4" type="text"
                                       value="${endtime1!}" data-date-format="yyyy-mm-dd">
                            </div>
                        <@searchSelect label="状态" name="status" valueMap={"wait":"待处理","go":"已出发","success":"已完成","cancel":"已取消"} isEnd=true></@searchSelect>
                        <#if sessionAdmin.type == 'admin'>
                        <div class="input-group ">
                            <button name="export" class="btn btn-primary" style="margin: 6px">
                                导出
                            </button>
                        </div>
                        </#if>

                        </form>
                        <div class="form-tool btn-group">
                            <a class="btn btn-primary" href="/orders/add">添加</a>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>

                            <#if sessionAdmin.type == 'admin'>
                                <@tableHead names=["会员名","身份证","联系方式","产品名称","登记日期","出发日期","返回日期","天数","价格","店铺","保险","状态","计算费用","收益","客服","备注","操作"]></@tableHead>

                           <#else>
                                <@tableHead names=["会员名","身份证","联系方式","产品名称","登记日期","出发日期","返回日期","天数","价格","店铺","保险","状态","客服","备注","操作"]></@tableHead>
                            </#if>

                            </tr>
                            </thead>
                            <tbody>
                            <#list pageInfo.list as item>

                            <tr>
                                <td><#if item.member??>${item.member}<#else>${item.name2!}</#if></td>
                                <td><#if item.card??>${item.card}<#else>${item.card2!}</#if></td>
                                <td><#if item.phone??>${item.phone}<#else>${item.phone2!}</#if></td>
                                <@tableBody model=item propMap={"name":"","enrolldate":"","godate":"","backdate":"","day":"#0","price":"#0.00","user":"","safe":""}></@tableBody>

                                <td>${item.status?switch("wait","待处理","go","已出发","success","已完成","cancel","已取消")}</td>
                                <#if sessionAdmin.type == 'admin'>
                                    <@tableBody model=item propMap={"balance":"#0.0","profit":"#0.0"}></@tableBody>
                                </#if>
                                <td>${item.kefu!}</td>
                                <td>${item.remark!}</td>
                                <td>
                                    <#if sessionAdmin.type == 'admin'>
                                    <a href="${basePath}/orders/detail/${item.id}">修改记录</a>
                                    </#if>
                                    <a href="javascript:if(confirm('确定取消出行吗？')){location.href='${basePath}/orders/cancel/${item.id}'}">取消出行</a>

                                    <#if item.status=='wait'>
                                        <a href="javascript:if(confirm('确定已经出发了吗？')){location.href='${basePath}/orders/go/${item.id}'}">已出发</a>
                                    </#if>

                                    <#if sessionAdmin.type == 'admin'>
                                        <a href="javascript:if(confirm('确定要删除吗？')){location.href='${basePath}/orders/del/${item.id}'}">删除</a>
                                    </#if>

                                    <#if item.status != 'success' && sessionAdmin.type == 'admin'>
                                        <a href="#" onclick="balance('${item.id}')">去结算</a>
                                    </#if>

                                    <#if item.status != 'success' && sessionAdmin.type == 'admin'>
                                        <a href="javascript:if(confirm('确定已经完成了吗？')){location.href='${basePath}/orders/complete/${item.id}'}">已完成</a>
                                    </#if>
                                </td>
                            </tr>
                            </#list>
                            </tbody>
                        </table>
                    <#include "../common/table-page.html"/>
                    <#if sessionAdmin.type == 'admin'>
                        <div class="pull-right">
                            <#if priceSum??>
                                <span>计算费用总计：${priceSum.price?string("#0.00")}&nbsp;&nbsp;&nbsp;</span>
                                <span>利润总计：${priceSum.profit?string("#0.00")}</span>
                            </#if>
                        </div>
                    </#if>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">结算出行</h4>
            </div>
            <form action="/orders/balance" method="post">
                <input type="hidden" name="id" id="id">
                <div class="modal-body">
                <@formAddNum label="结算价格" name="balance"></@formAddNum>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>

        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<script>

    $('.date-picker').datetimepicker({autoclose: true, language: 'zh-CN', minView: 2});

    function balance(id) {
        $("#id").val(id);
        $("#myModal").modal("show");
    }
</script>
</body>
</html>

